import os
import json
from distutils.util import strtobool

DEBUG = strtobool(os.environ.get("DEBUG", "True"))

# ###############token过期时间####################
TOKEN_EXPIRE = 60 * 60 * 24 * 365

# ###############SCHEDULE的RPC地址###################
SCHEDULE_RPC_IP = os.environ.get("SCHEDULE_RPC_IP", "10.12.3.162:31817")
IMLF_GRPC_IP = os.environ.get("IMLF_GRPC_IP", "10.12.3.162:30561")

# ###############admin设置####################
ADMIN_NAME = "admin"
ADMIN_GROUP_NAME = "admin"
ADMIN_EMAIL = "demo@goldwind.com.cn"
ADMIN_PASSWORD = "admin123456"

SECRET_KEY = "kjisdhtknasdktnhast"

FRONT_URL = "http://54.223.29.113:8893"

# ###############邮箱设置####################
MAIL_SERVER = "EX01.goldwind.org"
MAIL_PORT = 587  # SSL（Security Socket Layer,安全套接字层）和TLS（Transport Layer Sceurity，传输层安全）是两种常用的电子邮件安全协议
MAIL_USE_TLS = True
MAIL_USE_SSL = False
MAIL_USERNAME = os.environ.get("MAIL_USERNAME", "zhengshuiqing@goldwind.com").strip()
MAIL_PASSWORD = os.environ.get("MAIL_PASSWORD", "zsq,./110").strip()
MAIL_DEFAULT_SENDER = os.environ.get(
    "MAIL_DEFAULT_SENDER", "zhengshuiqing@goldwind.com"
).strip()
if not MAIL_PASSWORD:
    raise ValueError("必须填写MAIL_PASSWORD")

class RULE_MOD:
    MIN = "minimum"
    MAX = "maximum"
    UCROSS = "up_cross"
    DCROSS = "down_cross"
    LT = "lt"      # 小于
    GT = "gt"      # 大于
    LE = "le"      # 小于等于
    GE = "ge"      # 大于等于
    LTN = "ltn"      # 倒数第n个小于倒数第n个,0代表数
    GTN = "gtn"      # 倒数第n个大于倒数第n个,0代表数
    LEN = "len"      # 倒数第n个小于等于倒数第n个,0代表数
    GEN = "gen"      # 倒数第n个大于等于倒数第n个,0代表数

# (orient, indicator, kwargs, condition)

# indicator_strategy_rules = {
#     "5日单均线买入": [1, "SMA", json.dumps({"period":5}), "minimum-L0"],
#     "5日单均线卖出": [-1, "SMA", json.dumps({"period":5}), "maximum-L0"],
#     "5日10日双均线金叉买入": [1, "DMA", json.dumps({"period1":5, "period2":10}), "up_cross-L0-L1"],
#     "5日10日双均线死叉卖出": [-1, "DMA", json.dumps({"period1":5, "period2":10}), "down_cross-L0-L1"],
# }

DEFAULT_CAL_EXCHANGE = "SSE"
